package com.powernode.factory;

import com.powernode.strategy.LoginStrategy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author 梁卓
 * @Version 1.0
 * @ClassName LoginStrategyFactory
 * @Description 登录策略工厂类
 * @Date 2024/07/20 23:31
 */
@Component
public class LoginStrategyFactory {

    /**
     * @Service("xxxx") 已经在容器中进行注册了，已经有值了
     */
    @Resource
    private Map<String, LoginStrategy> loginStrategyMap = new HashMap<>();

    /**
     * 用户的具体登录策略
     * @param loginType 登录类型
     * @return 登录策略类
     */
    public LoginStrategy getInstance(String loginType) {
        return loginStrategyMap.get(loginType);
    }

}
